package com.njitzx.controller;


import com.njitzx.entity.po.Consignee;
import com.njitzx.service.ConsigneeService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.njitzx.entity.vo.Result;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
import lombok.RequiredArgsConstructor;



import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 收货人表 前端控制器
 * </p>
 *
 * @author 周鑫
 * @since 2024-08-20
 */
@Api(tags = "收货人表接口")
@RestController
@RequestMapping("/consignee")
@RequiredArgsConstructor
public class ConsigneeController {

    private final ConsigneeService consigneeService;

    @ApiOperation("收货人表分页查询")
    @GetMapping("/list")
    public Result findPage(@ApiParam("页码") @RequestParam(defaultValue = "1") Integer pageNum,
                               @ApiParam("页大小") @RequestParam(defaultValue = "5") Integer pageSize,
                               @ApiParam("查询条件") Consignee consignee){
        PageInfo<Consignee> pageInfo = consigneeService.findPage(pageNum,pageSize,consignee);
        return Result.success(pageInfo);
    }

    @ApiOperation("根据主键查询收货人表")
    @GetMapping("/{consId}")
    public Result findById(@PathVariable Serializable consId){
        return Result.success(consigneeService.findById(consId));
    }

    @ApiOperation("新增收货人表")
    @PostMapping
    public Result add(@RequestBody Consignee consignee){
        consigneeService.add(consignee);
        return Result.success();
    }

    @ApiOperation("修改收货人表")
    @PutMapping
    public Result modify(@RequestBody Consignee consignee){
        consigneeService.modify(consignee);
        return Result.success();
    }

    @ApiOperation("根据主键删除收货人表")
    @DeleteMapping("/{consId}")
    public Result removeById(@PathVariable Serializable consId){
        consigneeService.removeById(consId);
        return Result.success();
    }

}
